package com.jewaton.auth.commons.service;

import com.jewaton.auth.commons.entity.AccountRole;
import com.jewaton.auth.commons.entity.OperateAuth;
import com.jewaton.auth.commons.entity.Permission;
import com.jewaton.auth.commons.entity.Role;
import com.jewaton.auth.commons.util.Pager;

import java.util.List;
import java.util.Map;

/**
 * RBAC（Role-Based Access Control，基于角色的访问控制）
 *
 */
public interface RBACService {
    
    /*
     * ----------共同部分 begin -------------
     */
    
    public void addRole(Role role);
    
    public void addAccountRole(AccountRole accountRole);
    
    public Role findRoleById(long rid);
    
    public Role findRoleByName(String roleName);
    
    public OperateAuth findOAuthById(Long oauthId);
    
    public Permission getPermByOauthId(Long oauthId);
    
    public Permission getPermByMenuId(Long menuId);
    
    public void updateRole(Role role);
    
    public void updatePermission(Permission permission);
    
    public void updateOauth(OperateAuth oauth);
    
    public void deleteRole(long rid);
    
    public void delRoles(String ids);
    
    public void assginRolePermission(String originPids, String changePid, long rid);
    
    public void flush();
    
    
    /*
     * ----------共同部分 end  -------------
     */
    
    
    public List<Map<String, Object>> getAssginRoleByOrgId(long aid,String oid);
    
    public Pager<Role> getAllPcRole(int pageNo, int pageSize,String roleName, String oid);    
    
    public void assginAccountRole(String originRids, String changeRids, long aid);
    
    public List<Map<String,Object>> getPcPermissionTree(boolean showCode);
    
    public List<Map<String,Object>> getPcPermissionTreeOfOrg(String oid, boolean showAll,boolean setChecked, boolean showCode);
    
    public List<Map<String,Object>> getPcPermissionTreeOfRole(String oid, long rid, boolean showAll, boolean showCode);
    
    public List<Map<String,Object>> viewPcPermissionTreeOfOrg(String oid, boolean showCode);
    
    public List<Map<String,Object>> viewPcPermissionTreeOfRole(String oid, long rid, boolean showCode);
    
    public void updatePcOrgPermissions(String oid, String originPermissions,
            String changePermissions);

}
